package com.ww.testclient.order.rpcApi;

import com.ww.microrpc.MicroRpcClient;
import com.ww.microrpc.RpcMapping;
import com.ww.microrpc.netty.handler.client.SendCallback;
import com.ww.testserver.order.OrderEntity;

@MicroRpcClient(name = "test-service-rpc", url = "${example-server-url}", fallback = OrderServiceFallback.class)
public interface OrderServiceApi {

    /**
     * 同步请求：
     * <p>
     * 直接返回结果，发生错误时抛出异常 示例：
     * <p>
     * OrderEntity submitOrder(OrderEntity order);
     * <p>
     * 使用ResponseHolder对结果进行包装，用来获取到错误信息 示例：
     * <p>
     * ResponseHolder<OrderService> submitOrder(OrderEntity order);
     */
//    OrderEntity submitOrder(OrderEntity order);

    @RpcMapping(targetClass = "orderService", targetMethod = "submitOrder")
    OrderEntity submitOrder(OrderEntity order);

    /**
     * 异步请求：
     * 最后一个参数传入SendCallback的一个实现类，该请求会立即返回，然后通过SendCallBack异步处理结果
     */
    void submitOrder(OrderEntity order, SendCallback sendCallback);

}
